/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package momo.impl;

import momo.Control;
import momo.MomoPackage;
import momo.OutPut;
import momo.ViewFrame;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Control</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link momo.impl.ControlImpl#getFrameViewer <em>Frame Viewer</em>}</li>
 *   <li>{@link momo.impl.ControlImpl#getOutput <em>Output</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ControlImpl extends EObjectImpl implements Control {
	/**
	 * The cached value of the '{@link #getFrameViewer() <em>Frame Viewer</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getFrameViewer()
	 * @generated
	 * @ordered
	 */
	protected ViewFrame frameViewer;

	/**
	 * The cached value of the '{@link #getOutput() <em>Output</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getOutput()
	 * @generated
	 * @ordered
	 */
	protected OutPut output;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected ControlImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return MomoPackage.Literals.CONTROL;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public ViewFrame getFrameViewer() {
		return frameViewer;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetFrameViewer(ViewFrame newFrameViewer, NotificationChain msgs) {
		ViewFrame oldFrameViewer = frameViewer;
		frameViewer = newFrameViewer;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MomoPackage.CONTROL__FRAME_VIEWER, oldFrameViewer, newFrameViewer);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setFrameViewer(ViewFrame newFrameViewer) {
		if (newFrameViewer != frameViewer) {
			NotificationChain msgs = null;
			if (frameViewer != null)
				msgs = ((InternalEObject)frameViewer).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MomoPackage.CONTROL__FRAME_VIEWER, null, msgs);
			if (newFrameViewer != null)
				msgs = ((InternalEObject)newFrameViewer).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MomoPackage.CONTROL__FRAME_VIEWER, null, msgs);
			msgs = basicSetFrameViewer(newFrameViewer, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MomoPackage.CONTROL__FRAME_VIEWER, newFrameViewer, newFrameViewer));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public OutPut getOutput() {
		return output;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetOutput(OutPut newOutput, NotificationChain msgs) {
		OutPut oldOutput = output;
		output = newOutput;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, MomoPackage.CONTROL__OUTPUT, oldOutput, newOutput);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setOutput(OutPut newOutput) {
		if (newOutput != output) {
			NotificationChain msgs = null;
			if (output != null)
				msgs = ((InternalEObject)output).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - MomoPackage.CONTROL__OUTPUT, null, msgs);
			if (newOutput != null)
				msgs = ((InternalEObject)newOutput).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - MomoPackage.CONTROL__OUTPUT, null, msgs);
			msgs = basicSetOutput(newOutput, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, MomoPackage.CONTROL__OUTPUT, newOutput, newOutput));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case MomoPackage.CONTROL__FRAME_VIEWER:
				return basicSetFrameViewer(null, msgs);
			case MomoPackage.CONTROL__OUTPUT:
				return basicSetOutput(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case MomoPackage.CONTROL__FRAME_VIEWER:
				return getFrameViewer();
			case MomoPackage.CONTROL__OUTPUT:
				return getOutput();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case MomoPackage.CONTROL__FRAME_VIEWER:
				setFrameViewer((ViewFrame)newValue);
				return;
			case MomoPackage.CONTROL__OUTPUT:
				setOutput((OutPut)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case MomoPackage.CONTROL__FRAME_VIEWER:
				setFrameViewer((ViewFrame)null);
				return;
			case MomoPackage.CONTROL__OUTPUT:
				setOutput((OutPut)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case MomoPackage.CONTROL__FRAME_VIEWER:
				return frameViewer != null;
			case MomoPackage.CONTROL__OUTPUT:
				return output != null;
		}
		return super.eIsSet(featureID);
	}

} //ControlImpl
